<?php 
namespace App\Models;

class Shop extends BaseModel
{
	protected $table = 'cut_shops';
	
	public function setPicsAttribute($pics) {
		if (\is_array($pics)) {
			$this->attributes['pics'] = json_encode($pics);
		}
	}
	public function getPicsAttribute($pics) {
		return \json_decode($pics, true);
	}
	
	public function products()
	{
		return $this->hasMany('App\Models\Product','shop_id');
	}
	
	public function coupons()
	{
		return $this->belongsToMany('App\Models\Coupon', 'cut_shop_coupons', 's_id', 'c_id')->where('cut_coupons.is_active', '=', 1);
	}
}
